<?php
session_start();
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if(!isset($_SESSION['name'])||empty ( $_SESSION['name'])){
     header('Location: login.php');
}
$dir=trim($_SESSION['code']);

if(isset($_FILES['file'])){
    $upload=uploadPhoto('file',6, $dir,$_FILES['file']['name']);
    if($upload)
        echo "uploaad succeful<br>";
    else
        echo "erooooooooooooooooooooooooooooor<br>";
}


if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh))) {
            if(preg_match("/[a-z0-9_]\.[a-z]/i", $file))
             echo "<A href=\"$dir/$file\"><img src=\"$dir/$file\" width=50 height=50></a><br>";
        }
        closedir($dh);
    }
}
?>
